#ifndef _MEMPOOL_H_
#define _MEMPOOL_H_

#include <vector>

class MemPool
{
	struct FreeList
	{
		FreeList* m_next;
	};

	std::vector<void*>	m_chunks;				// The chunks allocated by this Pool.
	FreeList*			m_freelist;				// The list of free objects.
	size_t				m_object_size;			// The number of bytes in an object.
	size_t				m_object_alignment;		// The alignment of an object.
	size_t				m_num_objects;			// The number of objects in a chunk.
	size_t				m_num_allocated;		// The number of objects currently allocated.

public:
	MemPool( size_t objectSize, size_t objectAlignment, size_t numObjects );
	~MemPool();
	void* Allocate( size_t objectSize );
	void Deallocate( void* address );
	size_t Allocated() const;

private:
	void Resize();
};

#endif